package com.erb.service.zwj.impl;

import com.erb.entity.Admin;
import com.erb.mapper.AdminMapper;
import com.erb.service.zwj.IAdminService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;

import javax.annotation.Resource;

@Transactional
@Service("adminService")
public class AdminServiceImpl implements IAdminService {
	@Resource
	private AdminMapper adminMapper;

	/**
	 * 通过管理员ID查询信息
	 *
	 * @param id
	 * @return
	 */
	@Override
	public Admin findAdminById(long id) {
		if (id > 0) {
			return adminMapper.selectAdminById(id);
		}
		return null;
	}

	/**
	 * 通过管理员账号和密码查询信息
	 *
	 * @param username
	 * @param password
	 * @return
	 */
	@Override
	public Admin findAdminForLogin(String username, String password) {
		if (ObjectUtils.isEmpty(username) || ObjectUtils.isEmpty(password)) {
			return null;
		}
		return adminMapper.selectAdminForLogin(username, password);
	}
}
